from django.conf.urls import patterns, include, url
from rarebooks import settings
from goodies.forms import *
#from goodies.views import ContactWizard
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
#from haystack.views import SearchView
#from haystack.query import SearchQuerySet
#from haystack.forms import FacetedSearchForm
#from dajaxice.core import dajaxice_autodiscover, dajaxice_config
#dajaxice_autodiscover()

admin.autodiscover()
from grappelli.urls import urlpatterns as grappelli_urls


urlpatterns = patterns('goodies.views',
    # Examples:
    #url(r'^$', 'rarebooks.views.home', name='home'),
    #url(r'^rarebooks/', include('rarebooks.foo.urls')),

#    url(r'^main/$',                              'index'),
#    url(r'^main/category/(?P<category_id>\d+)/(?P<book_id>(?:\d+))/$','select_category'),#
#

#    url(r'^main/news$',                           'news'),
#    url(r'^main/news/(?P<news_id>\d+)/$',         'news'),#

#    url(r'^main/search/(?P<news_id>\d+)/$',         'news'),#
#

#    url(r'^main/non_loop_stuff/(?P<stuff_id>\d+)/$','non_loop_stuff'),#
#
#

#    url(r'^personal$',                                      'personal'),#

#    url(r'^personal/history/(?P<order_id>(?:\d+)+)$',       'history'),
#                 
#    url(r'^personal/addresses/(?P<address_id>(?:\d+))/(?P<action>(?:\w+))$','addresses'),#
#

#    url(r'^personal/basket/(?P<action>(?:\d+))/(?P<book_id>(?:\d+))$',     'basket'),#

#    url(r'^personal/basket/order',                'order'),
#    url(r'^personal/basket/submit_order',         'submit_order'),#
#

#    url(r'^personal/register$',          'register'),
#    url(r'^personal/login$',             'login'),
#    url(r'^personal/logout$',            'logout'),


#    url(r'^test_form/$',                 'test_form'),
#    url(r'^main/category/(?P<category_id>\d+)/$','select_category'),
#    #url(r'^contact/$', ContactWizard.as_view([ContactForm1, ContactForm2])),
#    url(r'^buy/$',     'test_form_2'),
#    url(r'^basket/$',  'basket'),
#    #url(r'^personal/register$',  'register'),
#    url(r'^personal/login$',     'login'),
#    url(r'^personal/logout$',    'logout'),
#    url(r'^main/search$',        'search'),
#    url(r'^ajax_example$',       'ajax_example'),
#    url(r'^personal/basket/$',   'basket'),#

#    url(r'^personal/buy_form$',  'buy_form'),
#    url(r'^personal/submit$',    'submit'),
#    url(r'^personal/history$',   'personal_history'),
#    url(r'^main/$',              'main_page')

#    ,
    url(r'^main/search$',        'search'),
    url(r'^main_jquery/$',        'main_jquery'),
    url(r'^(?P<parent>\d+)(?:/(?P<child>\d+))?/$','main_jquery'),
    url(r'^register/$',          'register'),
    url(r'^personal/$',          'personal'),
    url(r'^confirm/$',           'confirm'),
    url(r'^history/$',           'history'),
    url(r'^history_item/$',      'history_item'),
    url(r'^book_item/$',         'book_item'),
    url(r'^search/$',            'search'),
    url(r'^login/$',            'login'),
    url(r'^book_item/$',        'book_item'),
    url(r'^basket/$',           'basket'),





    

#    url(r'^(?P<path>(?:\d+/)+)(?P<action>\w+)', 'traverse_categories'),
#    #url(r'^(?P<path>(?:\d+/)+)(?P<action>\w+))/(?P<exact>(?:\d+/)+)', 'traverse_categories'),
#    url(r'^buy/(?P<book_id>))$',          'buy'),
   )

urlpatterns += patterns('',
    (r'^media/(?P<path>.*)$', 'django.views.static.serve', {
    'document_root': settings.MEDIA_ROOT}),

    url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    url(r'^admin/', include(admin.site.urls)),
    url(r'^grappelli/', include(grappelli_urls)))
  #  url(dajaxice_config.dajaxice_url, include('dajaxice.urls')))


#urlpatterns += patterns('haystack.views',
#    url(r'^$', SearchView(form_class=SuperForm, searchqueryset=sqs), name='haystack_search'),
#)
#

#urlpatterns += patterns('',(r'^search/', include('haystack.urls')))

